<?php

namespace app\models;

use Yii;
use app\models\News;
/**
 * This is the model class for table "{{%user}}".
 *
 * @property int $id
 * @property string $uid 用户uid
 * @property string $nickname 昵称
 * @property string $email 用户邮箱
 * @property string $password 登录密码
 * @property int $status 状态 0 正常 1 锁号
 */
class User extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%user}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['uid', 'status'], 'integer'],
            [['nickname', 'email', 'password'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'uid' => Yii::t('app', '用户uid'),
            'nickname' => Yii::t('app', '昵称'),
            'email' => Yii::t('app', '用户邮箱'),
            'password' => Yii::t('app', '登录密码'),
            'status' => Yii::t('app', '状态 0 正常 1 锁号'),
        ];
    }

    public function getNews()
    {
        return $this->hasMany(News::className(), ['author' => 'uid']);
    }

}
